import sys
sys.path.append('depends')

import simplejson
import twitter
import getpass
import urllib
from xml.dom import minidom



def youtubeAPI(url):
    query = url.split("?")[-1]
    params = dict([param.split('=') for param in query.split('&')])
    print str(params)
    id = params['v']
    
    call = "http://gdata.youtube.com/feeds/api/videos/" + id
    
    dom = minidom.parse(urllib.urlopen(call))
    for node in dom.getElementsByTagNameNS('http://www.w3.org/2005/Atom', 'title'):
        print node.firstChild.data  
    
    return id

url = "http://www.youtube.com/watch?v=m35zNXq7C0s&feature=popular"
print youtubeAPI(url)
"""
user = raw_input('Username: ')
password = getpass.getpass()

api = twitter.Api(user,password)

updates = api.Get362Timeline()
print "Total Timeline:"
for update in updates:
    print update.user.screen_name + " - " + update.text + " >> "   + str(update.in_reply_to_status_id)
"""